package com.schedule.task;

import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;

import org.apache.log4j.Logger;

import com.connect.report.file.processor.ReportGenerator;

public class ReportSchedulerTask {
	private static final Logger logger = Logger.getLogger(ReportSchedulerTask.class);
	private ReportGenerator reporGenerator;
	private String acqId;
	private String issrId;
	public ReportSchedulerTask(ReportGenerator reportGenerator, String acqId, String issrId){
		this.reporGenerator = reportGenerator;
		this.acqId = acqId;
		this.issrId = issrId;
	}
	public void reportTask(){
		String date = getDate();
		logger.debug("=============== started generated report ===============");
		try {
			reporGenerator.generatedReport(date, issrId,acqId);
		} catch (IOException e) {
			logger.debug("Exception file for File IO",e);
		}
		logger.debug("=============== end generated report =================");
	}
	private String getDate(){
		DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
		Calendar cal = Calendar.getInstance();
		cal.add(Calendar.DATE, -1);
		return dateFormat.format(cal.getTime());
	}
}
